package com.fd;

import com.fd.confing.Dog;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class FdApplication {
    public static void main(String[] args) {
        //在启动类中SpringApplication.run返回的是一个Spring高级容器
        final ConfigurableApplicationContext applicationContext = SpringApplication.run(FdApplication.class, args);

        //查看当前容器中的Bean
        String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
        for (String beanDefinitionName : beanDefinitionNames) {
            System.out.println("beanDefinitionName = " + beanDefinitionName);
        }
        int beanDefinitionCount = applicationContext.getBeanDefinitionCount();
        System.out.println("当前容器Bean的数量 beanDefinitionCount = " + beanDefinitionCount);

        //SpringApplication.run(FdApplication.class, args);
    }

    @Bean
    public Dog getDog() throws Exception {
        return new Dog();
    }
}

